<?php

use Illuminate\Support\Facades\View;
class LoginController extends BaseController {
	
	public function postCreate() {
		$params = array(
			'username' => Input::get('username'),
			'password' => Input::get('password')
		);
		
		if (Input::get('rememberMe') === 'true') {
			$rememberMe = true;
		} else {
			$rememberMe = false;
		}
		
		if (Auth::attempt($params, $rememberMe)) {
			return Redirect::to('dashboard');
		} else {
			return Redirect::to('/')
				->with('message', 'Usuário/senha incorreto.');
		}
	}
	
	public function getIndex() {
		if (Auth::check()) {
			return Redirect::to('dashboard');
		}
		
		return View::make('login');
	}
	
	public function getLogout() {
		Auth::logout();
		return Redirect::to('/');
	}
	
}